{template 'admin','header'}
<script language="javascript">
function change_adstype(obj)
{
	var typelist = {json_encode(array_keys($advertis->typelist))};
	var current = obj.value;
	var len = typelist.length
	var current_div = '';
	var nodes = '';
	for(i=0; i<len; i++)
	{
		current_div = document.getElementById('div_'+typelist[i]);
		nodes = current_div.childNodes;
		if(typelist[i] == current)
		{
			current_div.style.display='';
			for(j=0;j<nodes.length;j++)
			{
				if(nodes[j].tagName=='INPUT')
				{
					nodes[j].disabled = false;
				}
			}
		}
		else
		{
			current_div.style.display='none';
			for(j=0;j<nodes.length;j++)
			{
				if(nodes[j].tagName=='INPUT')
				{
					nodes[j].disabled = true;
				}
			}
		}
	}
}
</script>

<form action="{URL}" method="POST" enctype="multipart/form-data" onsubmit="return r_submit(this);">
<table class="table_form">
	<caption>添加广告</caption>
	<tr><th width="20%"><font color="red">*</font><strong>广告名称</strong></th><td><input type="text" name="adsname"></td></tr>
	<tr><th width="20%"><strong>广告描述</strong></th><td><input type="text" name="description"></td></tr>
	<tr>
		<th width="20%"><strong>广告类型</strong></th>
		<td>
			{loop $advertis->typelist $key $types}
			{if !isset($i)}
			{php $i=1; $flag=1}
			{else}
			{php $flag=0}
			{/if}
				<input type="radio" {if $flag==1}checked{/if} onclick="change_adstype(this)" name="adstype" value="{$key}">{$types['name']}
			{/loop}
		</td>
	</tr>
	<tr>
		<th width="20%"><strong>广告内容</strong></th>
		<td>
			<div id="div_text" >
				<input type="text" name="adscontent">
			</div>
			<div id="div_image" style="display:none;">
				上传图片：<input type="file" name="file"><br>
				链接地址：<input type="text" name="linkurl">
			</div>
			<div id="div_flash" style="display:none;">
				上传flash：<input disabled type="file" name="file"><br>
				链接地址：<input disabled type="text" name="linkurl">
			</div>
			<div id="div_link" style="display:none;">
				链接内容：<input disabled type="text" name="adscontent"><br>
				链接地址：<input disabled type="text" name="linkurl">
			</div>

		</td>
	</tr>
	<tr><th width="20%"></th><td><input type="submit" value=" 确定 " class="button_style">&nbsp;<input type="button" class="button_style" onclick="self.location='{urldecode($forward)}'" value=" 返回 "></td></tr>
</table>
</form>
{template 'admin','footer'}